#include <stdio.h>

#define address 0x3e


extern void I2CTransmitMultiple(unsigned int, char *, unsigned int);

void LCD_Init(){

	char testString[] = {0x00, 0x38, 0x00, 0x39, 0x14, 0x79, 0x50, 0x6c, 0x0c, 0x01};	//as per datasheet

	unsigned long i;

	I2CTransmitMultiple(address, testString, 10);

	for(i=0;i<10000;i++){};
}

void LCD_Cursor_Blink_On(){
	char sentence[] = {0x00, 0x0d};

	I2CTransmitMultiple(address, sentence, 2);
}

void LCD_Cursor_Blink_Off(){
	char sentence[] = {0x00, 0x0c};

	I2CTransmitMultiple(address, sentence, 2);
}

void LCD_Write(){
	/*TODO*/
}

void LCD_Clear(){
	char sentence[] = {0x00, 0x01};

	I2CTransmitMultiple(address, sentence, 2);
}

void LCD_ClearLine(){
	char sentence[] = "@                ";
//	unsigned long i;

	I2CTransmitMultiple(address, sentence, 17);

/*	for(i=0;i<10000;i++){};

  	char testString[] = "GOBBluth";
	unsigned int number = 40;
	char testString6[] = "@Password=goAway";
	char testString5[20];
	sprintf(testString5,"@%d%s454",number,testString);

	LCD_Row1();
	LCD_ClearLine();
	LCD_Row1();
	I2CTransmitMultiple(address, testString5, strlen(testString5));
	LCD_Row2();
	LCD_ClearLine();
	LCD_Row2();
	I2CTransmitMultiple(address, testString6, strlen(testString6));*/
}

void LCD_Row1(){
	char sentence[] = {0x00, 0x80};

	I2CTransmitMultiple(address, sentence, 2);
}

void LCD_Row2(){
	char sentence[] = {0x00, 0xc0};

	I2CTransmitMultiple(address, sentence, 2);
}

void LCD_Home(){
	char sentence[] = {0x00, 0x02};

	I2CTransmitMultiple(address, sentence, 2);
}

void LCD_On(){
	char sentence[] = {0x00, 0x0c};

	I2CTransmitMultiple(address, sentence, 2);
}

void LCD_Off(){
	char sentence[] = {0x00, 0x08};

	I2CTransmitMultiple(address, sentence, 2);
}
